package Collection;

import javafx.print.Collation;

import java.util.ArrayList;
import java.util.Collection;

public class Collectiondemo {
    public static void main(String[] args) {
        //集合中存放的是元素的引用
        Collection cc = new ArrayList();
        priot pp = new priot(1,2);
        cc.add(pp);//将pp添加到cc中----将pp的引用装到了cc中
        System.out.println(pp);
        System.out.println(cc);



        Collection collection = new ArrayList();
        collection.add(new priot(1,2));
        collection.add(new priot(3,4));
        collection.add(new priot(5,6));
        collection.add(new priot(7,8));
        collection.add(new priot(9,0));
        collection.add(new priot(1,2));
        System.out.println(collection);
        /**
         * boolean contains(Object o)
         * 判断当前集合是否包含给的元素o
         * 判断依据是给定元素是否与当前集合存在equals（）比较为TRUE的情况
         * */
        priot p = new priot(1,2);
        boolean contains = collection.contains(p);
        System.out.println(contains);
        /**
         * boo;ean remove(Object o)---一般都不接收Boolean结果‘
         * 从当前集合中删除与给定的元素o的equals（）比较为TRUE的元素
         * 若有重复的元素只删除一次*/
        collection.remove(p);
        System.out.println(contains);


       /* collection.add("aaa");
        collection.add("bbb");
        collection.add("ccc");
        collection.add("ddd");
        collection.add("eee");
        System.out.println(collection);

        System.out.println(collection.size());//输出集合的个数
        //判断isEmpty（）判断集合是否空集
        System.out.println(collection.isEmpty());

        collection.clear();
        System.out.println("集合清空");
        System.out.println(collection);
        System.out.println(collection.size());
        System.out.println(collection.isEmpty());*/
    }
}
